package com.zcf.service;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.zcf.common.json.Body;
import com.zcf.mapper.PumpingMapper;
import com.zcf.mapper.ServiceMapper;
import com.zcf.pojo.Pumping;
import com.zcf.vo.out.LayuiJson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ZhaoQi
 * @since 2019-03-18
 */
@Service
public class PumpingServiceImpl {

	@Autowired
	PumpingMapper pumpingMapper;
	/**
	 * 后端获取设置信息
	 * @return
	 */
	public LayuiJson getPumping(Integer gameType) {
		LayuiJson lj = new LayuiJson();
		List<Pumping> pumpings = pumpingMapper.selectList(new EntityWrapper<Pumping>().eq("game_type", gameType));
		if(pumpings.size()>0){
			 lj.setCode(0);
			 	lj.setCode(0);
	            lj.setCount(pumpings.size());
	            lj.setMsg("yes");
	            lj.setData(pumpings);
	            return lj;
		}
		lj.setCode(1);
        lj.setCount(0);
        lj.setMsg("no data");
        lj.setData(null);
        return lj;
	}

	/**
	 * 修改相关信息
	 * @return
	 */
	@Transactional(rollbackFor = Exception.class)
	public Body update(Pumping pumping) {
		boolean b =  pumping.updateById();
		return b ?  Body.BODY_200 : Body.BODY_451;
	}
	
	
	
	
}
